<?PHP
 //静态字典维护
class Admin_list_Controller extends controller_admin{
	function __construct(){
		parent::__construct();
	 	$this->assign('nav','静态字典维护');
		$this->assign('menuid1','6');
		$this->assign('menuid2','4'); 
		//权限判断
		factory::module('admin')->authSys('list');
	}
	var $lists = array(
		'user_classes'=>"会员类型",
		'identname'=>"证件类型",
		'source'=>"客户来源",
		'zone'=>"小区名称",
		'sendtime'=>"配送时间段"
	);
	function index__(){
		$rs = array(
			array(
				'type_name'=>"会员信息字段",
				'lists'=>$this->lists
			)
		);
		$this->assign('rs',$rs);
	}
	function info__(){
		if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')
		{
		 
		}
		$_GET=format::addslash_deep($_GET);
		$key = $_GET['key'];
		if(!isset($this->lists[$key])){
			url::msgbox('暂无此静态字典维护，请联系系统管理员！');
		}
		$listname = $this->lists[$key];
		$rs = factory::module('list')->getlist($key);
		$this->assign('rs',$rs);
		$this->assign('key',$key);
		$this->assign('listname',$listname);
		
	}
	
	
	
	/* 添加 */
	function add__(){
		$_POST=format::addslash_deep($_POST);
		$db = factory::getDBO();
		$max = $db->loadresult('select max(show_index) from t_list_'.$_POST['key'].' ') + 1;
		$rs = array(
			'val'=>$_POST['val'],
			'show_index'=>$max
		);
		if($db->insert('list_'.$_POST['key'],$rs)){
			exit('{success:1}');
		}else{
			exit('系统繁忙，请稍后重试！');
		}
	}
	
	/* 删除 */
	function del__(){
		$_POST=format::addslash_deep($_POST);
		$db = factory::getDBO();
		$id = $_POST['id'];
		//if( $db->loadresult('select count(*) from `t_vege` where type_id="'.$id.'" ') > 0 ){
		//	exit('操作失败，该类别下已经存在菜品！');
		//}	
		if($db->query('update  t_list_'.$_POST['key'].' set deleted=1 where id="'.$id.'" ')){
			exit('{success:1,msg11:"删除成功！"}');
		}else{
			exit('系统繁忙，请稍后重试！');
		} 
	}	
	/* 保存修改 */
	function modify__(){
		$objs = format::addslash_json(json_decode( stripslashes($_POST['objs']) ));
		$db = factory::getDBO();
		if($db->updatelist('list_'.$_POST['key'],$objs)){
			exit('{success:1,msg:"保存成功！"}');
		}else{
			exit('系统繁忙，请稍后重试！');
		}
	}	
	
	 
 
 
}
?>